<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
  PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="${package}.dao.${table.name?cap_first}Dao" > 
<!-- Result Map-->
<resultMap id="BaseResultMap" type="${package}.entity.${table.name?cap_first}" >
	<#list fieldColMap as fieldName, colName>
		<result column="${colName}" property=${fieldName} />
	</#list>
</resultMap>
    
<!-- wx_weight table all fields -->
<sql id="Base_Column_List" >
	<trim  suffixOverrides="," >
		<#list fieldColMap as fieldName, colName>
			${colName},
		</#list>
	</trim>	
</sql>

<#assign prefix="#">
   
<!-- 查询条件 -->
<sql id="Where_Clause">
where 1=1
 <trim  suffixOverrides="," >
	<#list fieldColMap as fieldName, colName>
		<if test="${colName} !=null and ${colName}!=''">
			and ${colName}=${prefix}{${fieldName}},
		</if>
	</#list>
 </trim>
</sql>
   
<!-- 插入记录 -->
<insert id="add" parameterType="Object" >
  insert into ${tableOriginalName}(
  		<trim  suffixOverrides="," >
  			<#list fieldColMap as fieldName, colName>
				${colName},
			</#list>
		</trim>	
) values(
		<trim  suffixOverrides="," >
			<#list fieldColMap as fieldName, colName>
				${prefix}{${fieldName}},
			</#list>
		</trim>	
)
</insert>

<!-- 根据id，修改记录-->  
 <update id="update" parameterType="Object" >
  update ${tableOriginalName} set
  	<trim  suffixOverrides="," > 
  		<#list fieldColMap as fieldName, colName>
			${colName}=${prefix}{${fieldName}},
		</#list>
	</trim>	
	where id==${prefix}{id}
 </update>
 
 <!-- 修改记录，只修改只不为空的字段 -->
<update id="updateBySelective" parameterType="Object" >
	update  ${tableOriginalName} set 
		<trim  suffixOverrides="," >
			<#list fieldColMap as fieldName, colName>
				<if test="${colName} != null  ">
					${colName}=${prefix}{${fieldName}},
				</if>
			</#list>	
		</trim> 
	where id==${prefix}{id}
</update>

<!-- 删除记录 -->
<delete id="delete" parameterType="Object">
	delete 	from  ${tableOriginalName}  where id = =${prefix}{id}
</delete>
 
<!-- 根据id查询 -->
<select id="queryById"  resultMap="BaseResultMap" parameterType="Object">
	select <include refid="Base_Column_List" /> 
	 from   ${tableOriginalName}   where id = =${prefix}{id}
</select>

<!--  列表总数-->
<select id="queryCount" resultType="java.lang.Integer"  parameterType="Object">
	select count(1) from   ${tableOriginalName}   
	<include refid="Where_Clause"/>
</select>
  	
<!--查询列表 -->
<select id="queryList" resultMap="BaseResultMap"  parameterType="Object">
	select 
	<include refid="Base_Column_List"/>
	from   ${tableOriginalName}    
	<include refid="Where_Clause"/>
	
</select>
  	
<！--if test="pager.orderCondition != null and pager.orderCondition != ''" >
      {pager.orderCondition}
    </if -->


</mapper>   
